package com.lingjtx.common.core.constant;

public enum MqttAction {
    STATUS("status"), // 上下线

    SWITCH_STATUS("switchstatus"), // 开关状态

    REPORT_DATA("reportdata"), // 数据上报

    OTA("ota"),

    EVENT("event"), // 事件

    INFO("info"), // 设置参数

    RENEW("renew"), // 设备刷新数据

    GATEWAY("gateway"), // 设置mqtt网关
    ;
    private final String action;

    MqttAction(String action) {
        this.action = action;
    }

    public String getAction() {
        return action;
    }

    public static MqttAction of(String action) {
        for (MqttAction mqttAction : MqttAction.values()) {
            if (mqttAction.getAction().equals(action)) {
                return mqttAction;
            }
        }
        return REPORT_DATA;
    }

    @Override
    public String toString() {
        return getAction();
    }
}
